﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace GDD2_Game3
{
    class KeyboardManager
    {
        private static KeyboardState kbState;
        private static KeyboardState previousKbState;
		private static MouseState mouseState;
		private static MouseState previousMouseState;

        static KeyboardManager()
        {
			previousKbState = kbState = new KeyboardState();
			previousMouseState = mouseState = new MouseState();
        }
        //makes sure that the keypress only gets called once
        public static bool singleKeyPress(Keys k)
        {
            return kbState.IsKeyDown(k) && previousKbState.IsKeyUp(k);
        }

        public static bool heldKeyPress(Keys k)
        {
            return kbState.IsKeyDown(k) && previousKbState.IsKeyDown(k);
        }

		public static bool singleMouseClick()
		{
			return mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released;
		}

		public static bool heldMouseClick()
		{
			return mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Pressed;
		}

		public static void update()
		{
			previousKbState = kbState;
			kbState = Keyboard.GetState();
			previousMouseState = mouseState;
			mouseState = Mouse.GetState();
		}
    }
}
